﻿Public Class Frm_Direction
    Dim aray As New List(Of String)
    Private Sub Frm_Direction_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Frm_Envois.Enabled = True

    End Sub

    Private Sub Frm_Direction_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txt_direction.Select()
        Partager.RemplirList(List_direction, "Comb_direction", "direction")
    End Sub

    Private Sub btn_ajout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ajout.Click
        Partager.AjouterWadifa(txt_direction, List_direction, "Comb_direction", "direction")
        Partager.com_ville(Frm_Envois.Comb_direction, "Comb_direction", "direction")
    End Sub

    Private Sub btn_supp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_supp.Click
        Partager.DeleteFromList(List_direction, "Comb_direction", "direction", txt_direction)
        Partager.com_ville(Frm_Envois.Comb_direction, "Comb_direction", "direction")
    End Sub

    Private Sub txt_direction_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt_direction.TextChanged
        Try
            List_direction.Items.Clear()
            Partager.Remplir(aray, "Comb_direction", "direction")
            For Each item As String In aray
                If item.ToString.Contains(txt_direction.Text) Then
                    List_direction.Items.Add(New ListViewItem(New String() {item.ToString}))
                End If
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        If txt_direction.Text = "" Then
            Partager.RemplirList(List_direction, "Comb_direction", "direction")
        End If
    End Sub

    Private Sub List_direction_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles List_direction.DoubleClick
        If List_direction.SelectedIndices.Count > 0 Then
            Frm_Envois.Comb_direction.Text = List_direction.SelectedItems(0).Text
            Me.Close()
        End If
    End Sub
End Class